import request from '@/router/axios'
export default () => ({

    /**
     * @description 字典数据列表
     * @description http://yapi.xiya.vip/project/11/interface/api/75
     */
    DICTDATA_ALL(id) {
        return request({
            url: '/regis/dict/itemList/'+ id,
            method: 'get'
        })
    },
    fetchClassKindList(query) {
        return request({
            url: '/regis/classkind/page',
            method: 'get',
            params: query
        })
    },

    addClassKind(obj) {
        return request({
            url: '/regis/classkind',
            method: 'post',
            data: obj,
            headers:{
                'Content-Type':'application/json'  //如果写成contentType会报错
            }

        })
    },

    getClassKind(id) {
        return request({
            url: '/regis/classkind/' + id,
            method: 'get'
        })
    },

    delClassKind(id) {
        return request({
            url: '/regis/classkind/' + id,
            method: 'delete'
        })
    },
    putClassKind(obj) {
        return request({
            url: '/regis/classkind',
            method: 'put',
            data: obj
        })
    },
    fetchTemplateConfigList(query) {
        return request({
            url: '/regis/templateconfig/page',
            method: 'get',
            params: query
        })
    },

    addTemplateConfig(obj) {
        return request({
            url: '/regis/templateconfig',
            method: 'post',
            data: obj
        })
    },

    getTemplateConfig(id) {
        return request({
            url: '/regis/templateconfig/' + id,
            method: 'get'
        })
    },
    fetchTemplateGroupList(query={}) {
      return  request({
        url: '/regis/templategroup/page',
        method: 'get',
        params: query
      })
    },
    delTemplateConfig(id) {
        return request({
            url: '/regis/templateconfig/' + id,
            method: 'delete'
        })
    },
    putTemplateConfig(obj) {
        return request({
            url: '/regis/templateconfig',
            method: 'put',
            data: obj
        })
    },

    addTemplateGroup(obj) {
        return request({
            url: '/regis/templategroup',
            method: 'post',
            data: obj
        })
    },

    getTemplateGroup(id) {
        return request({
            url: '/regis/templategroup/' + id,
            method: 'get'
        })
    },

    delTemplateGroup(id) {
        return request({
            url: '/regis/templategroup/' + id,
            method: 'delete'
        })
    },
    putTemplateGroup(obj) {
        return request({
            url: '/regis/templategroup',
            method: 'put',
            data: obj
        })
    },
    fetchTemplateList(query) {
        return request({
            url: '/regis/template/page',
            method: 'get',
            params: query
        })
    },

    addTemplate(obj) {
        return request({
            url: '/regis/template',
            method: 'post',
            data: obj
        })
    },
    saveTemplate(obj) {
      return request({
        url: '/regis/template/save',
        method: 'post',
        data: obj
      })
    },
    getTemplate(id) {
        return request({
            url: '/regis/template/' + id,
            method: 'get'
        })
    },

    delTemplate(id) {
        return request({
            url: '/regis/template/' + id,
            method: 'delete'
        })
    },
    putTemplate(obj) {
        return request({
            url: '/regis/template',
            method: 'put',
            data: obj
        })
    },
    getDutyRecordList(obj) {
      return request({
        url: '/regis/dutyrecord/list',
        method: 'post',
        data: obj
      })
    },
    getScheduleForDoctorList(obj) {
        return request({
            url: '/regis/dutyrecord/doctor',
            method: 'post',
            data: obj
        })
    },
    genSchedule(obj) {
        return request({
            url: '/regis/dutyrecord/gen/schedule',
            method: 'get',
            params: obj
        })
    },
    putBatchDutyRecord(obj){
        return request({
            url: '/regis/dutyrecord/batch',
            method: 'put',
            data: obj
        })
    },
    getWareList(obj){
        let wareList = Vue.ls.get('WARE_LIST')
        if(wareList) {
            return new Promise((resolve, reject) => {
                // 一段耗时的异步操作
                resolve(wareList)
            })
        }
        return request({
            url: '/regis/doctor/ware',
            method: 'get',
            params: obj
        }).then(res=>{
            Vue.ls.set('WARE_LIST',res.data.data,7*60 * 60 * 1000)
            return res.data.data
        })
    },
    getDoctorList(obj){
        return request({
            url: '/regis/doctor/list',
            method: 'get',
            params: obj
        })
     },
    getPatientList(obj){
        return request({
            url: '/regis/patient/list',
            method: 'get',
            params: obj
        })
    },
    saveGuahao(obj){
        return request({
            url: '/regis/guahao/save',
            method: 'post',
            data: obj
        })
    },
    getGuahaoList(obj){
        return request({
            url: '/regis/guahao/list',
            method: 'get',
            params: obj
        })
    }
})
